package bu.met.cs664;

import java.util.ArrayList;
import java.util.EnumSet;

/**
 * Created by mcox on 10/9/14.
 */
public enum Attributes {
    STENCH('S'),
    BREEZY('B'),
    GOLD('G'),
    WUMPUS('W'),
    DEAD_WUMPUS('X'),
    SCREAM('M'),
    PIT('P'),
    ENTER('E');

    private char attribute;

    private Attributes(char attribute) {
        this.attribute = attribute;
    }

    public char toChar() {
        return attribute;
    }

    public static EnumSet<Attributes> fromString(String inputs) {
        if (inputs == null || inputs.length() == 0) {
            return EnumSet.noneOf(Attributes.class);
        }

        ArrayList<Attributes> parsedAttributes = new ArrayList<Attributes>();

        for (char attribute : inputs.toCharArray()) {
            for (Attributes attributes : Attributes.values()) {
                if (attributes.toChar() == attribute) {
                    parsedAttributes.add(attributes);
                }
            }
        }

        return EnumSet.copyOf(parsedAttributes);
    }
}
